//模拟条件变量

#pragma once

#include<iostream>
#include <pthread.h>
#include "Mutex.hpp"

using namespace MutexModule;
namespace CondMoudle
{
    class Cond
    {
        public:
        Cond()
        {
            pthread_cond_init(&_cond, nullptr);
        }

        void Signal()
        {
            pthread_cond_signal(&_cond);
        }

        void Wait(Mutex &lock)
        {
            pthread_cond_wait(&_cond, lock.Get());
        }

        void Broadcast()
        {
            pthread_cond_broadcast(&_cond);
        }

        ~Cond()
        {}
        private:
        pthread_cond_t _cond;
    };
}